Graceful SP consume error handling - #3
Open
nerdyworm wants to merge 1 commit into
Open
Conversation
On consume failure, auto-retry the signin once for session-loss shaped errors (invalid relay state / idp id / target url). The retry marker is carried in the RelayState, which the IdP echoes back, so the loop guard holds even when the session cookie is what's broken. Repeat or non-recoverable failures render a human error page with a try-again link instead of a raw access_denied 403. Malformed SAMLResponses (esaml raises) now also get the error page instead of a 500.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
SP consume failures (
invalid_relay_stateetc.) returned a rawaccess_denied403 — a dead end for users whose session cookie didn't round-trip between signin and the IdP's consume POST (replayed/refreshed response, second login tab, dropped cookie in Citrix-style browser contexts). Malformed SAMLResponses crashed to a 500 because esaml raises. Surfaced by Houston Methodist users; consumed by blockit/api#6660.What
invalid_relay_state/invalid_idp_id/invalid_target_url) 302 back to a fresh signin with?samly_retry=1. The IdP usually still holds a live SSO session, so the retry completes without user interaction.retry_. RelayState is echoed back by the IdP, so the guard holds even when the session cookie is the thing that's broken — a second failure cannot redirect-loop.{:error, :malformed_response}and get the same page instead of a 500.IdP-initiated flow and all validation logic are unchanged.
Testing
Covered by
apps/blockit_web/test/blockit_web/sso_consume_error_test.exsin blockit/api#6660: retry redirect, loop guard, error page, malformed-response handling through the real endpoint, and the marker riding through the signin auto-submit form.🤖 Generated with Claude Code